package com.roc.common;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.commons.lang3.StringUtils;

public class PageContext {

	private int pageSize = 200;

	private int totalSize = 0;

//	private int totalPage = 1;
	// 当前页数
	private int currentPage = 1;

	private List<? extends Serializable> content = new ArrayList<Serializable>();

	private Map<String, Object> parameters = new HashMap<String, Object>();

	private Serializable example;

	private Boolean success;

	private String message;

	/**
	 * @return the content
	 */
	public List<? extends Serializable> getContent() {
		return content;
	}

	/**
	 * @param content
	 *            the content to set
	 */
	public void setContent(List<? extends Serializable> content) {
		this.content = content;
	}

	public int getPageSize() {
		return pageSize;
	}

	public int getTotalPage() {
		return totalSize % pageSize == 0 ? totalSize / pageSize : (totalSize
				/ pageSize + 1);
	}

	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}

	public int getCurrentPage() {
		return currentPage;
	}

	public void setCurrentPage(int currentPage) {
		this.currentPage = currentPage;
	}

	public int getCurrentStart() {
		return pageSize * (getCurrentPage() - 1);
	}

	public int getCurrentEnd() {
		return pageSize * getCurrentPage();
	}

	/**
	 * @return the parameters
	 */
	public Map<String, Object> getParameters() {
		return parameters;
	}

	/**
	 * @param parameters
	 *            the parameters to set
	 */
	public void setParameters(Map<String, Object> parameters) {
		this.parameters.putAll(parameters);
	}

	public void addParam(String key, Object value) {
		this.parameters.put(key, value);
	}

	public Object removeParam(String key) {
		return this.parameters.remove(key);
	}

	public Object getParam(String key) {
		return this.parameters.get(key);
	}

	/**
	 * @return the totalSize
	 */
	public int getTotalSize() {
		return totalSize;
	}

	/**
	 * @param totalSize
	 *            the totalSize to set
	 */
	public void setTotalSize(int totalSize) {
		this.totalSize = totalSize;
	}

	/**
	 * @return the example
	 */
	public Serializable getExample() {
		return example;
	}

	/**
	 * @param example
	 *            the example to set
	 */
	public void setExample(Serializable example) {
		this.example = example;
	}

	public Boolean getSuccess() {
		return success;
	}

	public void setSuccess(Boolean success) {
		this.success = success;
	}

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}

}
